#include "../header/common.h"

void burn(SDL_Rect victim,SDL_Surface *screen)
{
  SDL_Surface *burns,*background;
  SDL_Rect burn;
  int shift;
  switch(screen->w)
    {
    case 640 :
      burns = SDL_LoadBMP("image/640480/burn.bmp");
      background = SDL_LoadBMP("image/640480/background.bmp");
      break;
    case 800 :
      burns = SDL_LoadBMP("image/800600/burn.bmp");
      background = SDL_LoadBMP("image/800600/background.bmp");
      break;
    case 1024 :
      burns = SDL_LoadBMP("image/1024768/burn.bmp");
      background = SDL_LoadBMP("image/1024768/background.bmp");
      break;
    }
  SDL_BlitSurface(screen,NULL,background,NULL);
  burn.x=0;
  burn.y=0;
  burn.w=burns->h;
  burn.h=burns->h;
  SDL_SetColorKey(burns, SDL_SRCCOLORKEY, SDL_MapRGB(burns->format, 255, 255, 255)); 
  play(5);
  for(shift=0;shift<(burns->w/burns->h);shift++)
    {
      SDL_BlitSurface(burns,&burn,screen,&victim);
      SDL_Flip(screen);
      SDL_Delay(50);
      burn.x+=burn.w;
      if(shift==(((burns->w)/(burns->h))/2))SDL_BlitSurface(background,&victim,screen,&victim);
    }
  SDL_BlitSurface(background,&victim,screen,&victim); 
  SDL_FreeSurface(burns);
  SDL_FreeSurface(background);
}

